package cn.iocoder.yudao.module.system.controller.admin.weChatWorkInterface;

import javax.xml.ws.WebServiceException;
import javax.xml.ws.Service;
import java.net.MalformedURLException;
import java.net.URL;

public class WeChatWorkClient {

    public static void main(String[] args) {
        try {
            // 创建ObjectFactory实例
            ObjectFactory objectFactory = new ObjectFactory();

            // 使用ObjectFactory创建TextMsgSend请求对象并设置参数
            TextMsgSend textMsgSendRequest = objectFactory.createTextMsgSend();
            textMsgSendRequest.setTouser("700385"); // 请替换为实际的用户ID
            textMsgSendRequest.setContent("               **预约成功**\n     预约座位：A区-18号座位\n     预约时间：2024-08-27 上午\n详情请在:我的->我的预约 中查看！<hr/><a href=\'https://seatreserve-test.fmc-asia.cn\'>详情</a>"); // 请替换为实际的消息内容
            textMsgSendRequest.setAgentid("1000010"); // 请替换为实际的应用ID

            // 获取WSDL文件的URL
            String wsdlLocation = "file:/D:/code/src/main/java/WeChatWorkInterfacefortextMsgSend.wsdl";
            URL url = new URL(wsdlLocation);

            // 创建WeChatWorkInterface1服务实例
            Service service = new WeChatWorkInterface1(url);

            // 获取WeChatWorkInterface1Soap端口实例
            WeChatWorkInterface1Soap port = service.getPort(WeChatWorkInterface1Soap.class);

            // 调用textMsgSend方法并获取响应
            String response = port.textMsgSend(textMsgSendRequest.getTouser(),
                    textMsgSendRequest.getContent(),
                    textMsgSendRequest.getAgentid());

            // 输出响应结果
            System.out.println("发送消息的响应结果：" + response);
        } catch (WebServiceException | MalformedURLException e) {
            e.printStackTrace();
        }
    }
}